﻿@model Forest.Cat.Admin.Models.JobHunting.SavedJobListModel
@using Forest.Cat.Admin.Extensions;
@{
    ViewBag.Title = "关注职位";
    Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml";
}
<div class="savedsearch_manage_right">
    <div class="savedsearch_manage_right_title">
        @ViewBag.Title</div>
    <div class="savedsearch_manage_right_box">
        <p>
            <b>目前有 @Model.SearchCount 条职位记录</b><span>（最多可收藏60条职位，每个职位最多保留180天）</span></p>
        <table cellpadding="0" cellspacing="0" class="rebook_tab" width="100%">
            <tr>
                <th>
                    <input type="checkbox" class="checkboxHeader" />
                </th>
                <th>
                    创建日期
                </th>
                <th>
                    职位
                </th>
                <th>
                    公司
                </th>
                <th>
                    工作地点
                </th>
                <th>
                    已发布天数
                </th>
                <th>
                    申请截至日期
                </th>
                <th>
                    操作
                </th>
            </tr>
            @foreach (var item in Model.SavedJobs)
            {
                <tr id=	'@item.Id'>
                    <td style="text-align: center; width: 30px;">
                        <input type="checkbox" class="checkboxItem" />
                    </td>
                    <td>
                        @item.DateSaved.ToString("yyyy-MM-dd")
                    </td>
                    <td>
                        @Html.ActionLink(item.JobTitle.Length > 12 ? item.JobTitle.Substring(0, 12) + "..." : item.JobTitle, "JobView", "Catalog",
                         new { area = "", id = item.JobPostingId }, new { @title = item.JobTitle })
                    </td>
                    <td>
                        @Html.ActionLink(item.CompanyName,
                                             "CompanyView", "Company", new { area = "", id = item.CompanyId }, new { @title = item.CompanyName })}
                    </td>
                    <td>
                        @item.Location
                    </td>
                    <td>
                        @item.PublishDays
                    </td>
                    <td>@item.EndDate.ToString("yyyy-MM-dd")
                    </td>
                    <td>
                        @using (Html.BeginForm("SavedJobDelete", "JobHunting", FormMethod.Post))
                        {
                            <span>
                                @Html.Hidden("DeleteId", item.Id.ToString())
                                <input type="submit" value="删除" onclick="return confirm('确定删除？');" />
                            </span>
                        }
                    </td>
                </tr>
            }
        </table>
        <div class="pages">
            <p>
                <a href="#">
                    @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber")
                </a>
            </p>
            @using (Html.BeginForm("SavedJobDeleteList", "JobHunting", FormMethod.Post))
            {
                @Html.Hidden("DeleteIdList", "")
                <input type="submit" value="删除所选记录" onclick="return GetSelectCheckBox();" />
            }
        </div>
    </div>
</div>
<script type="text/javascript" language="javascript">
    $(window).bind('load', function () {
        var cbHeader = $(".checkboxHeader");
        var cbRowItem = $(".checkboxItem");
        cbHeader.bind("click", function () {
            cbRowItem.each(function () { this.checked = cbHeader[0].checked; })
        });
        cbRowItem.bind("click", function () { if ($(this).checked == false) cbHeader[0].checked = false; });
    });

    function GetSelectCheckBox() {
        var ckList = $(".checkboxItem");
        var cknum = 0;
        var idList = new Array();
        ckList.each(function () {
            if (this.checked) {
                var id = $(this).parent().parent().attr("id");
                idList[cknum] = id;
                cknum = cknum + 1;
            }
        });

        if (cknum == 0) {
            alert("请至少选择一个checkbox");
            return false;
        }

        $("#DeleteIdList").val(idList);
        return confirm("确定删除？");
    }
</script>
